#BIOS配置脚本
#配置指令为. /devmem2 配置值 w 寄存器值#
#!/bin/bash
echo  "------Modify register value--------"
#cd  /home/benchmarks/STREM-master
time=`date '+%Y-%m-%d %H:%M:%S'`
rm -fr temp.txt
rm -fr config.txt
mv /home/yuytest/newhexbios/hexbios.txt /home/benchmarks/STREAM-master
dos2unix hexbios.txt
insmod  mem_development.ko
test1=`cat hexbios.txt | sed -n '1p'`
test2=`cat hexbios.txt | sed -n '2p'`
test3=`cat hexbios.txt | sed -n '3p'`
test4=`cat hexbios.txt | sed -n '4p'`
test5=`cat hexbios.txt | sed -n '5p'`
test6=`cat hexbios.txt | sed -n '6p'`
test7=`cat hexbios.txt | sed -n '7p'`
test8=`cat hexbios.txt | sed -n '8p'`
# test9=`cat hexbios.txt | sed -n '9p'`
#默认配置
#test1=0x430c800
#test2=0xddff973d
#test3=0x0000706f
#test4=0xf3773cfe
#test5=0xff7db008
echo  "L3T_STATIC_CTRL"
./devmem2 0x000090980000  w  $test1 >> config.txt
./devmem2 0x200090980000  w  $test1 >> config.txt
./devmem2 0x000098980000  w  $test1 >> config.txt
./devmem2 0x200098980000  w  $test1 >> config.txt
echo  "L3T_DYNAMIC_CTRL"
./devmem2 0x000090980400  w  $test2 >> config.txt
./devmem2 0x200090980400  w  $test2 >> config.txt
./devmem2 0x000098980400  w  $test2 >> config.txt
./devmem2 0x200098980400  w  $test2 >> config.txt
echo  "L3T_DYNAMIC_AUCTRL0"
./devmem2 0x000090980404  w  $test3 >> config.txt
./devmem2 0x200090980404  w  $test3 >> config.txt
./devmem2 0x000098980404  w  $test3 >> config.txt
./devmem2 0x200098980404  w  $test3 >> config.txt
echo  "L3T_DYNAMIC_AUCTRL1"
./devmem2 0x00009098040C  w  $test4 >> config.txt
./devmem2 0x20009098040C  w  $test4 >> config.txt
./devmem2 0x00009898040C  w  $test4 >> config.txt
./devmem2 0x20009898040C  w  $test4 >> config.txt
echo  "L3T_PREFECTH"
./devmem2 0x000090980410  w  $test5 >> config.txt
./devmem2 0x200090980410  w  $test5 >> config.txt
./devmem2 0x000098980410  w  $test5 >> config.txt
./devmem2 0x200098980410  w  $test5 >> config.txt
# echo  "l4t_prime_num_config1"
# ./devmem2 0X000090980554  w  $test6 >> config.txt
# ./devmem2 0x200090980554  w  $test6 >> config.txt
# ./devmem2 0x000098980554  w  $test6 >> config.txt
# ./devmem2 0x200098980554  w  $test6 >> config.txt
echo  "hha_dir_ctrl"
./devmem2 0X00009092000C  w  $test6 >> config.txt
./devmem2 0x20009092000C  w  $test6 >> config.txt
./devmem2 0x00009892000C  w  $test6 >> config.txt
./devmem2 0x20009892000C  w  $test6 >> config.txt
echo  "hha_func_dis"
./devmem2 0X000090920010  w  $test7 >> config.txt
./devmem2 0x200090920010  w  $test7 >> config.txt
./devmem2 0x000098920010  w  $test7 >> config.txt
./devmem2 0x200098920010  w  $test7 >> config.txt
echo  "mn_dynamic_ctrl"
./devmem2 0X000090330400  w  $test8 >> config.txt
./devmem2 0x200090330400  w  $test8 >> config.txt
./devmem2 0x000098330400  w  $test8 >> config.txt
./devmem2 0x200098330400  w  $test8 >> config.txt
# echo  "hha_totemnum"
# ./devmem2 0X000090920020  w  $test9 >> config.txt
# ./devmem2 0x200090920020  w  $test9 >> config.txt
# ./devmem2 0x000098920020  w  $test9 >> config.txt
# ./devmem2 0x200098920020  w  $test9 >> config.txt

echo  "------Running Stream test--------"
tuned-adm profile throughput-performance
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
export OMP_NUM_THREADS=128
export GOMP_CPU_AFFINITY=0-127
./stream_c.exe > temp.txt
cat temp.txt|grep -E "Copy|Scale|Add|Triad"|awk '{print $2}' > /home/yuytest/newgoal/result.txt
cat config.txt|grep -E "fail|success"|awk '{print $0}' >> /home/yuytest/newgoal/result.txt
echo 'stream' >> /home/yuytest/newgoal/result.txt
unix2dos /home/yuytest/newgoal/result.txt
rm -fr hexbios.txt
echo 3 > /proc/sys/vm/drop_caches